package com.carkeeper.utile;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class BcryptUtil {

    private static BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
    /**
     *  密码加密
     * @param password
     * @return
     */
    public static String encrypt(String password) {
        String newPassword = passwordEncoder.encode(password);
        return newPassword;
    }

    /**
     *  判断密码是否相同
     * @param password 需要校验的密码
     * @param newPassword 加密后的密码
     * @return
     */
    public static boolean matches(String password, String newPassword) {
        return passwordEncoder.matches(password, newPassword);
    }
}
